package utils

import (
	crand "crypto/rand"
	"math/big"
)

// RandStringCrypto 生成随机字符串-加密用-使用crypto/rand生成随机数
func RandStringCrypto(length int) string {
	str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	bytes := []byte(str)
	result := []byte{}
	for i := 0; i < length; i++ {
		j, _ := crand.Int(crand.Reader, big.NewInt(int64(len(bytes))))
		result = append(result, bytes[j.Int64()])
	}
	return string(result)
}
